<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateYPicturesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('y_pictures')) {
            Schema::create('y_pictures', function (Blueprint $table) {
                $table->engine = 'MyISAM';
                $table->increments('picture_id');
                $table->integer('picture_user_id')->default(0)->comment('用户id');
                $table->string('picture_thumbnail', 50)->default('')->comment('图片名称');
                $table->tinyInteger('picture_category_id')->default(0)->comment('所属组id');
                $table->tinyInteger('picture_check')->default(0)->comment('0未审核，1通过，2屏蔽');
                $table->tinyInteger('picture_status')->default(1)->comment('0已删除，1正常,2退赛');
                $table->integer('picture_health_point')->default(0)->comment('生命值');
                $table->integer('picture_likenum')->default(0)->comment('点赞数');
                $table->integer('picture_dislikenum')->default(0)->comment('失败数');
                $table->integer('picture_uprank_condition')->default(0)->comment('升级所需点赞数');
                $table->integer('picture_uprank_likenum')->default(0)->comment('此等级被点赞数');
                $table->smallInteger('picture_uprank_type')->default(1)->comment('下一等级升级类型');
                $table->integer('picture_rank_number')->default(0)->comment('等级');
                $table->timestamps();

                //索引
                $table->index('picture_user_id');
                $table->index('picture_thumbnail');
                $table->index('picture_type');
                $table->index('picture_check');
                $table->index('picture_status');
                $table->index('picture_health_point');
                $table->index('picture_likenum');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('y_pictures');
    }
}
